{template 'common/header'}
<div class="main">
	<ul class="nav nav-tabs">
		<li class="active">
			<a href="{php echo $this->createWebUrl('datimanage');}">答题管理</a>
		</li>
		<li>
			<a href="{php echo $this->createWebUrl('adddati');}">添加答题</a>
		</li>
		<li>
			<a href="{php echo $this->createWebUrl('importdati',array('rid'=>$rid));}">导入题库</a>
		</li>
	</ul>
	<div class="panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
					<tr>
						<th class='with-checkbox' style="width: 50px;"></th>
						<th style="width: 150px;">问题</th>
						<th style="width: 180px;">正确答案</th>
						<!-- <th style="width: 100px;">分值</th> -->
						<th style="width: 100px;">题目类型</th>
						<th style="width: 250px;">操作</th>
					</tr>
				</thead>
				<tbody>
					{loop $list $row}
					<tr>
						<td class="with-checkbox"><input type="checkbox" name="check" value="{$row['id']}"></td>
						<td>{$row['question']}</td>
						<td>{$row['realanswer']}</td>
						 <!--<td>{$row['points']}</td> -->
						{if $row['is_must']==0}
						<td>普通题</td>
						{/if}
						{if $row['is_must']==1}
						<td>必选题</td>
						{/if}
						<td>
							<a class="btn btn-default" data-toggle="tooltip" data-placement="top"
								href="{php echo $this->createWebUrl('adddati',array('rid'=>$row['rid'],'id'=>$row['id']))}"
								title="编辑"><i class="fa fa-edit"></i>
							</a> 
							<a class="btn btn-default" data-toggle="tooltip" data-placement="top" href="#"
								onclick="drop_confirm('您确定要删除吗?', '{php echo $this->createWebUrl('deletedati',array('rid'=>$row['rid'],'id'=>$row['id']))}');"
								title="删除"><i class="fa fa-times"></i>
							</a>
							
							
						</td>
					</tr>
					{/loop}
					<tr>
						<td><input type="checkbox" class="check_all" value="0" /></td>
						<td colspan="5"><input type="button" class="btn btn-primary"
							name="deleteall" value="删除选择的" /></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	{$pager}
</div>
<script>
require(['bootstrap'],function($){
	$('.btn').tooltip();
});
$(function(){
    $(".check_all").click(function(){
       var checked = $(this).get(0).checked;
		$(':checkbox').each(function(){this.checked = checked});
    });
	$("input[name=deleteall]").click(function(){
		var check = $("input:checked");
		if(check.length<1){
			alert('请选择要删除的记录!');
			return false;
		}
        if( confirm("确认要删除选择的记录?")){
			var id = new Array();
			check.each(function(i){
				if($(this).val()!=0){
					id[i] = $(this).val();
				}
			});
			$.post("{php echo $this->createWebUrl('deletetiall')}", {ridArr:id},function(data){
				if (data.errno ==0)
				{
					location.reload();
				} else {
					alert(data.error);
				}
	
	
			},'json');
		}
	});
});
</script>
<script>
function drop_confirm(msg, url){
    if(confirm(msg)){
        window.location = url;
    }
}
</script>
{template 'common/footer'}
